package org.ben.birthday.twentybirthday.utils;

import lombok.Data;

import java.io.Serializable;

/**
 * @Author: Ben
 * @Date: 2019/7/23 15:00
 */
@Data
public class Result implements Serializable {

    /**
     * 状态码
     */
    private int code;

    /**
     *状态信息
     */
    private String msg;

    /**
     * 数据
     */
    private Object data;

    /**
     * 数量
     */
    private int count;

    /**
     * 总页数
     */
    private long pages;

    /**
     * 当前页数
     */
    private long current;

    public Result(ResultCode resultCode, Object data) {
        this(resultCode);
        this.data = data;
    }
    public Result(ResultCode resultCode) {
        this.code = resultCode.getCode();
        this.msg = resultCode.getMsg();
    }
    public Result(ResultCode resultCode,String msg){
        this.code=resultCode.getCode();
        this.msg=msg;
    }
    public Result(ResultCode resultCode,String msg,int count,Object data){
        this.code=resultCode.getCode();
        this.msg=msg;
        this.data=data;
        this.count=count;
    }

    /**
     *分页数据
     * @param resultCode
     * @param msg
     * @param data
     * @param pages
     * @param current
     */
    public Result(ResultCode resultCode,String msg,Object data,long pages,long current) {
        this.code = resultCode.getCode();
        this.msg = msg;
        this.data = data;
        this.pages = pages;
        this.current = current;
    }

    @Override
    public String toString() {
        return "Result{" +
                "code=" + code +
                ", msg='" + msg + '\'' +
                ", data=" + data +
                '}';
    }
}
